<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />

<html>
	<head>
		<title>物流公司管理</title>
		<script type="text/javascript">
		var datatable_content ;
		$(function(){
			initTable();
		});
		function initTable(){
			datatable_content = $("#contentTable").dataTable({
			  "bServerSide":true,
	           "sAjaxSource":'${ctx}/v2/logistics/page',
	           "fnServerData": callback,
	           "bFilter": false,
	           "bSort": false,
	           "sZeroRecords": "查询无记录！",
	           "bProcessing": true, 
	           "oLanguage": {
	               "sUrl": '${ctx}/static/v2/js/plugins/datatables/cn.txt'
	            },
	             "aoColumns":[
	             	 {"mData": "companyName"},
	             	 {"mData": "companyCode"},
	             	 {"mData": "fullName"},
	             	 {"mData": "customerServiceTel"},
	             	 {"mData": "corpLevel"},
	             	 {"mData": "regMailNo"},
	             	 {"mData": "id"}, 
	             ],
	             "aoColumnDefs":[
	             	{"aTargets": [4],
		              "mRender": function (data, display, row) {
			        	 return data == "auth" ? "认证" : 
			        	        data == "noAuth" ? "未认证" : 
			        	        data == "brand" ? "品牌" : 
			        	        data == "normal" ? "普通" : "";
			           }
		            },
	             	 {"aTargets": [6],
		              "mRender": function (data, display, row) {
			        		var rs = "<a href=\"#\" id=\"confirm_"+data+"\" onclick=\"myConfirm("+data+")\" class=\"btn btn-sm btn-primary\">刪除</a>"+
								     "<a href=\"${ctx}/v2/logistics/update/"+data+"\" class=\"btn btn-sm btn-primary\">修改</a>";
							/* if(row.expressStyleSize == 0){
								rs += "<a href=\"${ctx}/v2/expressPrinting/addExpress/"+data+"\" class=\"btn btn-sm btn-primary\">增加快递单样式</a>";
							} */
						    return rs;
			           }
		            },
	             ],
			});
		}
		
		function callback( sSource, aoData, fnCallback ) {
		 aoData.push( { "name": "search_LIKE_fullName", "value": $("#search_LIKE_fullName").val()});  
			 //查询参数
		   $.ajax({ 
		       "type": "post",
		       "contentType": "application/json", 
		       "url": sSource,    
		       "dataType": "json",   
		       "data": JSON.stringify(aoData),
		       "success": fnCallback  
		   });    
		}
		
		function query(){
			datatable_content.fnDestroy();
			initTable();
		}
		
		function myConfirm(item){
		   if(confirm("确定要删除该物流公司吗？该物流公司的快递单信息也会删除！")){
		        window.self.location="${ctx}/v2/logistics/delete/"+item;
		   }
		}
</script>
	</head>
	<body>
	<section class="content">
		<div class="row">
		<div class="col-md-12">
			<div class="box box-solid box-primary">
			<div class="box-header">
					<i class="fa fa-search"></i>
					<h3 class="box-title">搜索栏</h3>
					<div class="box-tools pull-right">
						<button class="btn btn-primary btn-sm" data-widget="collapse">
							<i class="fa fa-minus"></i>
						</button>
					</div>
				</div>
				<div class="box-body">
				<form class="form-search" action="#">
					<div class="input-append">
					<span class="add-on">物流公司：</span>
					
					<input type="text" name="search_LIKE_fullName" class="input-medium" id="search_LIKE_fullName"
						value="${param.search_LIKE_fullName}" onkeydown='if(event.keyCode==13) {query(); return false;}'>
					<button type="button" class="btn btn-info" onclick="query()">
						搜索
					</button>
					<a class="btn btn-info" href="${ctx}/v2/logistics/create">增加物流公司</a>
					</div>
				</form>
			</div>
		</div>
		</div>
		</div>
	<c:if test="${not empty message}">
			<div id="message" class="alert alert-success alert-dismissable">
				<i class="fa fa-check"></i>
				<button data-dismiss="alert" class="close">
					×
				</button>
				${message}
			</div>
		</c:if>
	
	<div class="form-group row">
		<div class="col-md-12">
			<div class="box box-solid box-primary">
				<div class="box-header">
					<i class="fa fa-list"></i>
					<h3 class="box-title">查询结果</h3>
					<div class="box-tools pull-right">
						<button class="btn btn-primary btn-sm" data-widget="collapse">
							<i class="fa fa-minus"></i>
						</button>
					</div>
				</div>
				<div class="box-body">
		<table id="contentTable"
			class="table table-striped table-bordered table-condensed">
			<thead>
				<tr>
					<th>
						简称
					</th>
					<th>
						代码
					</th>
					<th>
						全称
					</th>
					<th>
						客服电话
					</th>
					<th>
						公司级别
					</th>
					<th>
						运单号校验码
					</th>
					<th>
						操作
					</th>
				</tr>
			</thead>
			<tbody>
			</tbody>
		</table>
		</div>
		</div>
		</div>
		</div>
</section>
	</body>
</html>
